package com.binfenhulian.chinaenergy.ces.crawler.controller;

import com.binfenhulian.chinaenergy.ces.core.bean.result.AjaxResult;
import com.binfenhulian.chinaenergy.ces.crawler.dispatcher.TaskDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by wanghjbuf on 2018/3/27.
 */
@Slf4j
@Controller
@RequestMapping("/crawler/remote")
public class RemoteController {

    @Autowired
    TaskDispatcher taskDispatcher;

    @RequestMapping("/docrawling")
    @ResponseBody
    public Object crawling(HttpServletRequest request, HttpServletResponse response) {

        log.info(">>>执行任务抓取操作<<<");

        taskDispatcher.doDispatch();
        return new AjaxResult(0, "执行抓取任务", true, null);
    }
}
